<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>background-change</title>
    <style>
        img{
            width: 300px;
            height: 300px;
            float: left;
            text-align: center;
        }
        fieldset{
            padding: 0;
            width: 300px;
            margin: 0 auto;
        }
    </style>
</head>
<body>
<!--    fieldset分组元素-->
    <fieldset>
<!--        legend 这一组的标题叫什么-->
        <legend style="text-align: center">点击按钮使页面变色</legend>
        <div id="btn">
            <input type="button" value="红色" id="red">
            <input type="button" value="绿色" id="green">
            <input type="button" value="蓝色" id="blue">
        </div>
    </fieldset>
    <script>
        var btn_red=document.getElementById("red")
        var btn_blue=document.getElementById("blue")
        var btn_green=document.getElementById("green")
        btn_red.onclick=function (){
            document.body.style.backgroundColor="red"
        }
        btn_blue.onclick=function (){
            document.body.style.backgroundColor="blue"
        }
        btn_green.onclick=function (){
            document.body.style.backgroundColor="green"
        }
    </script>
</body>
</html>